Repository navigation
Resync the object walk at handle-map offsets and report gaps (closes #13, closes #17) - #55
Merged
mahach666 merged 26 commits intoNov 20, 2026
Conversation
--- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-version: 18.12.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]>
--- updated-dependencies: - dependency-name: Microsoft.SourceLink.GitHub dependency-version: 10.0.404 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]>
The walk used to stop at the first zero run or broken record of AcDb:AcDbObjects and drop everything past it with no diagnostic. Now a stop point resynchronises at the next handle-map offset (the walk is driven by the map), each gap and each unrecoverable stop is reported in Diagnostics, and a lower inventory-versus-map count is reported as well. DwgHandleMap.Parse reports truncated blocks and drops negative-offset entries with a diagnostic instead of casting them away. Synthetic tests build two records with a zero run between them, plus a handle map that points at both: both objects are in the inventory, with a gap diagnostic. Fixture tests also skip drawings of an unsupported version and count them in the skip reason, so a single AC1021 drawing in the fixture folder no longer fails every test (#17).
The encryption check of every optional section reader now runs through one TryGetReadableSection helper: an encrypted section adds one diagnostic naming the section instead of the data going missing. dwgio inspect marks encrypted sections in the section table. A synthetic section map with encrypted entries is covered by tests; decrypting such sections stays out of scope.
A drawing without a thumbnail now exits with code 5 instead of the parse-error code 4, and a requested output extension that does not match the image kind is reported on standard error while the path is kept. The preview command writes through a TextWriter and its target resolution is extracted, both covered by CLI tests. The README and getting-started exit-code tables document code 5.
dwgio --version/-v prints the package version and --help/-h the usage, both with exit code 0; an unknown option still exits 1 (#18). dwgio entities <file.dwg> [--type LINE,CIRCLE] [--json] lists the decoded entities one line each or as a JSON array; the type filter is validated against the known type names with a clear error and exit code 1 (#19). The plain export writes to standard output when the target is '-', so the same JSON as to a file reaches a pipe (#19). The commands run through Run(args, output, error), which the CLI tests drive directly.
The ProductInformation XML that AppInfoParser stores in ProductXml
carries the product in its name attribute ("AutoCAD", "AutoCAD
LT", "Teigha(R)" per libredwg's appinfo.spec). Both the ANSI and
the UTF-16 layout now extract it into Product, so inspect's
product= and the JSON export name the product. Tests cover the
attribute, its absence, and the existing synthetic Writer case.
- AcDb:RevHistory: layout version pair and the list of save references, per libredwg's revhistory.spec. - AcDb:AuxHeader: the fixed 123-byte layout (intro marker, version pair, save counters, Julian-day creation and update times, next handle), with AutoCAD's R2018 variant normalised to the ODA order before the fields are read, per libredwg's auxheader.spec. - AcDb:Template: the counted description string and the unit system word, per libredwg's template.spec. - AcDb:AppInfoHistory: walked as a sequence of AppInfo records, one per earlier save; the layout is undocumented anywhere, so the walk is best effort and stops with a diagnostic where a record does not decode. Each is exposed on DwgDocument, written to the JSON export and summarised by dwgio inspect. Synthetic tests cover the parsers, including truncated inputs that produce diagnostics.
A drawing can now come from a stream: a network handle, an archive entry or an already-open file. The stream is read to memory once, so the results are identical to Open(path) on the same bytes, and the unsupported-version message names the source (the path or "stream"). The same-results gate runs on every available private drawing through a fixture test. Reading data pages on demand and the lazy object stream stay open; this change does not claim them.
…#34, #33) The build job now runs build+test+pack on windows-latest, ubuntu-latest and macos-latest for both target frameworks, replacing the Linux build-only job; the README sentence about Windows-only tests is updated. test-files/public is the folder for committed redistributable test drawings, with the origin and licence recorded next to each file; TestFiles searches it alongside DWGIO_TEST_FILES and test_files. The drawings themselves follow (#33 stays open until at least one drawing per supported release is committed).
#39) The fixed type codes come from libredwg's include/dwg.h and live in the public DwgObjectTypes: the name and the entity-or-object flag of every fixed code 0x01-0x52 plus the proxy codes. Wrong names are corrected (0x21 is SHAPE, ELLIPSE is 0x23; VERTEX_0B is VERTEX_3D), the missing ones are added (MINSERT, the seven DIMENSION variants, POLYLINE_PFACE/MESH, SOLID, TRACE, REGION, BODY, TOLERANCE, the table and control objects, LWPOLYLINE, PLACEHOLDER, VBA_PROJECT, LAYOUT, PROXY_ENTITY/OBJECT), OLE2FRAME and LWPOLYLINE count as entities, and class-defined codes (500+) are reported as Class_502 until the class list is decoded (#21). DwgObjectInfo.TypeName, the JSON byType keys and the type counts of dwgio inspect show the names. The README and docs/test-fixtures.md temper the AC1018 claim: implemented, not yet verified on a real drawing (#39).
docfx builds only docs/ and reports the file link outside its scope as an error; the GitHub blob URL works everywhere.
Same as the fix on the CI/fixture PR: docfx builds only docs/ and reports the out-of-scope file link as an error.
WriteObj replaced the MTL first and the OBJ second, so a failure of the second move left the old OBJ naming the new MTL. Now the old MTL is first renamed aside, the new MTL moves in, and the OBJ - which names that MTL in its mtllib - moves in last; on a failure at either move the old MTL steps back in (or a failed fresh export leaves no MTL behind) and the previous pair survives together. Tests inject both failures: the OBJ destination held open exclusively (Windows file lock; on Unix the rename would succeed, so the test skips there) and the old MTL held open, plus a platform-independent destination-as-directory case for the fresh export.
…9c63e180b10a5f232578d9ef96fd62c7c37e' into codex/fix-pr-stack
Add DwgDocument.Open(Stream) (first step of #37)
Read revision history, auxiliary header and template metadata (part of #36)
Fill DwgAppInfo.Product from the product XML (closes #35)
Give dwgio preview its own exit code and check the output extension (closes #14)
…tics Report skipped encrypted sections in Diagnostics and inspect (closes #38)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this does
Closes #13 and #17. Stacked on #50–#54.
#13 — the object walk stops at the first gap without a diagnostic
ObjectStreamWalker.Walknow takes the handle-map offsets and a diagnostic sink. At a stop point — a zero run (padding or erased bytes) or a broken record (torn body, size past the stream end, unterminated size) — it reports the stop and, when a handle-map offset lies beyond it, resumes there, so records past the gap are inventoried instead of silently lost. Without a recovering offset the walk stops with a diagnostic naming the offset and the reason.DwgDocument.ReadOptionalObjectsdrives the walk with the (deduplicated, ascending) handle-map offsets and adds an inventory-vs-map diagnostic when the inventory holds fewer records than the map lists entries.DwgHandleMap.Parsetakes an optional diagnostic sink: truncated blocks ("block at N is truncated…"), unreadable delta pairs, and entries with a negative offset (previously cast away) are reported; negative entries are dropped and counted.The exact synthetic reproduction from the issue is covered: two valid records separated by a run of zero bytes, plus a handle map pointing at both — both objects land in the inventory, with a gap diagnostic. Additional tests cover the unrecoverable stop, the clean stream, truncated handle-map blocks and negative offsets.
#17 — fixture tests fail on unsupported versions
CheckAllcatchesDwgUnsupportedVersionExceptionper file and counts it as ignored instead of failed; when no supported drawing exists the skip reason mentions the count.docs/test-fixtures.mddocuments it.Notes
RecordBitWriterreplaces the per-test writer.Tests
Full suite: 139 passed, 7 skipped (private fixtures).